home *** CD-ROM | disk | FTP | other *** search
/ Tech Win 1995 November / CD [TECH_B].bin / tech_b / delphi / trial / disk1 / mastapp.pak / MAIN.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-08-08  |  4.9 KB  |  163 lines

  1. {                           MastApp Main Window.
  2.  
  3.   By default, the database component's alias is DBDEMOS, and so the
  4.   application accesses the Paradox tables. To upsize the application
  5.   to Local Interbase Server, take the following steps:
  6.  
  7.   1   Pull down the Tools menu, launch Database Desktop and select its
  8.       File|Aliases... to create a new alias. Press the NEW button and name
  9.       the alias MASTSQL. Set the alias type to INTRBASE and specify a server
  10.       name of C:\DELPHI\DEMOS\DATA\MASTSQL.GDB. Set the user name to SYSDBA
  11.       and then press KEEP NEW.
  12.  
  13.   2   Enter the password "masterkey" (it MUST be entered in lowercase) and
  14.       press CONNECT in order to validate the alias you have just created.
  15.       (If you cannot connect, make sure the IBLOCAL bin directory is on your
  16.       DOS path and you specified the correct location for the MASTSQL.GDB
  17.       file. If you still cannot connect, refer to INSTALL.TXT and README.TXT
  18.       for more information.)
  19.  
  20.       Press DISCONNECT, OK and then answer YES when asked whether to save
  21.       these changes in your configuration file.
  22.  
  23.   3   Close the Database Desktop and return to Delphi. Close the project (in
  24.       order to close all open forms) then and re-open it by selecting
  25.       MASTAPP.DPR from the pick list at the bottom of the File menu.
  26.       Select the database component in the lower left corner of the MainForm
  27.       and set its Connected property to False. Click on the AliasName property's
  28.       dropdown list and select MASTSQL. (If MASTSQL is not listed, go back to
  29.       the Database Desktop and make sure you can connect from there). Finally,
  30.       set the Database component's Connected property to True, enter the
  31.       password ("masterkey") and run.
  32.  
  33.   You've just "upsized" MASTAPP to a client-server application! To switch
  34.   between the desktop and SQL versions, close all units and forms (the easiest
  35.   way is to close and re-open the project as instructed above), use the
  36.   Object Inspector to set MainForm.Database's Connected property to False, pick
  37.   an AliasName (DBDEMOS to use the Paradox database, MASTSQL to use
  38.   the Local InterBase Server version), and set Connected to True.
  39.   Now you're ready to run.
  40. }
  41.  
  42. unit Main;
  43.  
  44. interface
  45.  
  46. uses
  47.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  48.   Forms, Dialogs, Buttons, StdCtrls, Menus, ExtCtrls, DB;
  49.  
  50. type
  51.   TMainForm = class(TForm)
  52.     MainPanel: TPanel;
  53.     OrderBtn: TSpeedButton;
  54.     BrowseBtn: TSpeedButton;
  55.     PartsBtn: TSpeedButton;
  56.     CloseBtn: TSpeedButton;
  57.     Database: TDatabase;
  58.     MainMenu1: TMainMenu;
  59.     File1: TMenuItem;
  60.     PrinterSetup1: TMenuItem;
  61.     N3: TMenuItem;
  62.     N4: TMenuItem;
  63.     NewOrder2: TMenuItem;
  64.     N5: TMenuItem;
  65.     View1: TMenuItem;
  66.     Orders1: TMenuItem;
  67.     PartsInventiry1: TMenuItem;
  68.     Help1: TMenuItem;
  69.     About1: TMenuItem;
  70.     N7: TMenuItem;
  71.     StayOnTop2: TMenuItem;
  72.     HelpBtn: TSpeedButton;
  73.     N6: TMenuItem;
  74.     Contents1: TMenuItem;
  75.     PrinterSetup: TPrinterSetupDialog;
  76.     procedure BrowseCustOrd(Sender: TObject);
  77.     procedure CloseApp(Sender: TObject);
  78.     procedure FormCreate(Sender: TObject);
  79.     procedure BrowseParts(Sender: TObject);
  80.     procedure ToggleStayonTop(Sender: TObject);
  81.     procedure NewOrder(Sender: TObject);
  82.     procedure HelpBtnClick(Sender: TObject);
  83.     procedure PrinterSetupClick(Sender: TObject);
  84.     procedure AboutClick(Sender: TObject);
  85.     procedure FormDestroy(Sender: TObject);
  86.  
  87.   private
  88.   end;
  89.  
  90. var
  91.   MainForm: TMainForm;
  92.  
  93. implementation
  94.  
  95. uses CustOrd, BrParts, EdOrders, About, Custqry, IniFiles;
  96.  
  97. {$R *.DFM}
  98.  
  99. procedure TMainForm.BrowseCustOrd(Sender: TObject);
  100. begin
  101.   BrCustOrdForm.Show;
  102. end;
  103.  
  104. procedure TMainForm.CloseApp(Sender: TObject);
  105. begin
  106.   Close;
  107. end;
  108.  
  109. procedure TMainForm.FormCreate(Sender: TObject);
  110. var W: longint;
  111. begin
  112.   ClientWidth := CloseBtn.Left + CloseBtn.Width - 1;
  113.   ClientHeight := CloseBtn.Top + CloseBtn.Height - 1;
  114.   MainPanel.Align := alClient;
  115.   { position the form at the top of display }
  116.   Left := 0;
  117.   Top := 0;
  118. end;
  119.  
  120. procedure TMainForm.BrowseParts(Sender: TObject);
  121. begin
  122.   BrPartsForm.Show;
  123. end;
  124.  
  125.  
  126. procedure TMainForm.ToggleStayonTop(Sender: TObject);
  127. begin
  128.   with Sender as TMenuItem do
  129.   begin
  130.     Checked := not Checked;
  131.     if Checked then MainForm.FormStyle := fsStayOnTop
  132.     else MainForm.FormStyle := fsNormal;
  133.   end;
  134. end;
  135.  
  136. procedure TMainForm.NewOrder(Sender: TObject);
  137. begin
  138.   OrderForm.Enter;
  139.   ClientHeight := CloseBtn.Height - 1;
  140. end;
  141.  
  142. procedure TMainForm.HelpBtnClick(Sender: TObject);
  143. begin
  144.   Application.HelpCommand(HELP_CONTENTS,0);
  145. end;
  146.  
  147. procedure TMainForm.PrinterSetupClick(Sender: TObject);
  148. begin
  149.   PrinterSetup.Execute;
  150. end;
  151.  
  152. procedure TMainForm.AboutClick(Sender: TObject);
  153. begin
  154.   AboutBox.ShowModal;
  155. end;
  156.  
  157. procedure TMainForm.FormDestroy(Sender: TObject);
  158. begin
  159.   Application.HelpCommand(HELP_QUIT,0);
  160. end;
  161.  
  162. end.
  163.